/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EJB.Business;

import java.sql.Timestamp;
import javax.ejb.Stateless;
import java.util.List;
import Entity.*;
import EJB.Entity.*;
import javax.ejb.EJB;

@Stateless
public class GestorDeAdministrador implements GestorDeAdministradorLocal {
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

	private @EJB UsuarioFacadeLocal ufacade;
	private @EJB PedidoFacadeLocal pfacade;
	private @EJB PlatoFacadeLocal plfacade;
	private @EJB MesaFacadeLocal mfacade;
	private @EJB ReservaFacadeLocal rfacade;

    public GestorDeAdministrador(){
        ufacade = new UsuarioFacade();
        pfacade = new PedidoFacade();
        plfacade = new PlatoFacade();
        mfacade = new MesaFacade();
        rfacade = new ReservaFacade();
    }

    public List<Usuario> mostrarUsuarios(){
        return ufacade.findAll();
    }

    public List<Mesa> mostrarMesas(){
        return mfacade.findAll();
    }

    public List<Pedido> mostrarPedidos(){
        return pfacade.findAll();
    }

    public List<Reserva> mostrarReservas(){
        return rfacade.findAll();
    }

    public List<Plato> mostrarPlatos(){
        return plfacade.findAll();
    }

    public List<Reserva> mostrarReservasPorFecha(Timestamp fecha){
        return rfacade.findByDate(fecha);
    }
    
    public void agregarPlato(String[] params){  
		Plato nuevo = new Plato();
		nuevo.setValor(params[0]);
		nuevo.setImagen(params[1]);		
		nuevo.setTipo(Integer.parseInt(params[2]));
		nuevo.setNombre(params[3]);
    	plfacade.create(nuevo);
    }
    
    public void agregarMesa(Mesa m){
    	mfacade.create(m);
    }
    
    public void borrarPlato(Plato p){
    	plfacade.remove(p);
    }
    
    public void borrarMesa(Mesa m){
    	mfacade.remove(m);
    }
    
}
